package com.li.commons.pager;

import java.util.ArrayList;
import java.util.List;

public class Page<E> extends ArrayList<E>{

	private static final long serialVersionUID = -1637699426092986230L;

	private boolean count = false;
	private int pageNum;
	private int pageSize;
	private int startRow;
	private int endRow;
	private long total;
	private int pages;
	
	public Page(){
	}
	
	public Page(Integer pageNum,Integer pageSize,boolean count){
		this.pageNum=pageNum;
		this.pageSize=pageSize;
		this.pages = Double.valueOf(Math.ceil(total*1.0/pageSize)).intValue();
		this.startRow=(pageNum-1)*pageSize;
		this.endRow=startRow+pageSize;
		this.count = count;
	}
	
	public Page(Integer pageNum,Integer pageSize, Integer total, boolean count){
		this.pageNum=pageNum;
		this.pageSize=pageSize;
		this.pages = Double.valueOf(Math.ceil(total*1.0/pageSize)).intValue();
		this.total=total;
		this.startRow=(pageNum-1)*pageSize;
		this.endRow=startRow+pageSize;
		this.count=count;
	}
	
	public int getPageNum() {
		return pageNum<=0?1:pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getStartRow() {
		return startRow;
	}
	public void setStartRow(int startRow) {
		this.startRow = startRow;
	}
	public int getEndRow() {
		return endRow;
	}
	public void setEndRow(int endRow) {
		this.endRow = endRow;
	}
	public long getTotal() {
		return total;
	}
	public void setTotal(long total) {
		this.total = total;
	}
	public int getPages() {
		return pages;
	}
	public void setPages(int pages) {
		this.pages = pages;
	}

	public boolean isCount() {
		return count;
	}

	public void setCount(boolean count) {
		this.count = count;
	}
	
	public List<E> getResult() {
        return this;
    }
}